package com.lwq.feign;

import com.lwq.util.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author lwq
 */
@FeignClient("alibaba-product")
public interface ProductFeign {

    /**
     * 远程方法：通过主键查询一条商品记录
     *
     * @param id 商品主键
     * @return 对应主键的商品信息
     */
    @GetMapping("/api/v1/product/select-by-id")
    Result selectById(@RequestParam Integer id);

    /**
     * 远程方法：通过主键扣减指定商品的库存量
     *
     * @param id     商品主键
     * @param number 扣减量
     * @return 扣减结果
     */
    @PostMapping("/api/v1/product/reduce-inventory")
    Result reduceInventory(@RequestParam Integer id, @RequestParam Integer number);

}